package com.sltx.service.impl;


import com.sltx.dao.aaa.ResultMapper;
import com.sltx.service.ResultService;
import com.sltx.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class ResultServiceImpl implements ResultService {

    @Autowired
    private ResultMapper resultMapper;

    @Override
    public Map Condition(PageData pd) {
        int pageSize = Integer.parseInt(pd.get("pageSize").toString());
        int pageNum = Integer.parseInt(pd.get("pageNo").toString());
        Integer startPage = ((pageSize*(pageNum-1)));
        pd.put("startPage",startPage.toString());
        String page = resultMapper.getPackageNum(pd);
        List< Map<String, Object>> map1 =  resultMapper.Condition(pd);
        List<Map<String,Object>> list = resultMapper.getindustrycod(pd);
        List<String> list1 = new ArrayList<>();
        for (int i = 0; i < list.size(); i++) {
            String industrycoD = (String) list.get(i).get("industryco_d");
            list1.add(industrycoD);
        }
        Map map = new HashMap();
        map.put("enterprise",map1);
        map.put("count",page);
        map.put("hangyedaleiOver", list1);
        return map;
    }

    @Override
    public Map notMatch(PageData pd) {
        int pageSize = Integer.parseInt(pd.get("pageSize").toString());
        int pageNum = Integer.parseInt(pd.get("pageNo").toString());
        Integer startPage = ((pageSize*(pageNum-1)));
        pd.put("startPage",startPage.toString());
        List< Map<String, Object>> mapList = resultMapper.ConditionNO(pd);
        String pageNo = resultMapper.getPackageNumNo(pd);
        List<Map<String,Object>> list2 = resultMapper.getindustrycod2(pd);
        List<String> list3 = new ArrayList<>();
        for (int i = 0; i < list2.size(); i++) {
            String industrycoD = (String) list2.get(i).get("industryco_d");
            list3.add(industrycoD);
        }
        Map map = new HashMap();
        map.put("enterpriseNo",mapList);
        map.put("countNo",pageNo);
        map.put("hangyedaleiNo", list3);
        return map;
    }

}
